/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nuboat.easyjsf.util;

import java.security.MessageDigest;

/**
 *
 * @author nuboat
 */
public class MD5Encrypt {

    private MD5Encrypt() {}

    public static String getMessage(byte [] defaultBytes) {
        StringBuffer hexString = null;
        MessageDigest algorithm = null;
        try {
            algorithm = MessageDigest.getInstance("MD5");
            algorithm.reset();
            algorithm.update(defaultBytes);

            hexString = new StringBuffer();
            for (byte message :  algorithm.digest())
                hexString.append(Integer.toHexString(0xFF & message));

        } catch (Exception e) {
            System.out.println(e.getMessage());

        }
        return hexString.toString();
    }
}
